package com.softer.ztb.controller;

import com.softer.ztb.common.entity.ManagerPageResult;
import com.softer.ztb.common.entity.Page;
import com.softer.ztb.common.entity.ShiroCommonResult;
import com.softer.ztb.entity.SysRole;
import com.softer.ztb.entity.SysUser;
import com.softer.ztb.service.RoleService;
import com.softer.ztb.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
/**
 * RoleController class
 * @author zcz
 * @date 2019/1/16
 */
@RestController
@RequestMapping("/role")
@Slf4j
public class RoleController {
    @Autowired
    RoleService roleService;

    @RequestMapping("/add")
    public ShiroCommonResult add(SysRole role,HttpSession session) {
        role.setCreater(session.getAttribute("userName")+"");
        return roleService.insert(role);
    }
    @RequestMapping("/update")
    public ShiroCommonResult update(SysRole role) {
        return roleService.update(role);
    }
    @RequestMapping("/delete")
    public ShiroCommonResult delete(String id) {
        return roleService.delete(id);
    }
    @RequestMapping("/getRoleList")
    public ManagerPageResult getRoleList(Page page, SysRole role) {
        return roleService.getRoleList(page,role);
    }


}
